package com.wakala.employment.utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

public class OrderUtil {

    private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
    private static final Random random = new Random();

    public static String generateOrderNumber() {
        // 生成日期时间字符串
        String dateTime = dateFormat.format(new Date());
        // 生成随机数
        int randomNumber = random.nextInt(999999); // 生成六位数的随机数
        // 格式化随机数，确保六位数
        String formattedRandomNumber = String.format("%06d", randomNumber);
        // 拼接字符串作为订单号
        return "ORDER" + dateTime + formattedRandomNumber;
    }

    public static void main(String[] args) {
        String orderNumber = generateOrderNumber();
        System.out.println("Generated Order Number: " + orderNumber);
    }
}